package com.hospital.demo.controller.jiajinpeng;

import com.hospital.demo.model.jiajinpeng.Beds;
import com.hospital.demo.service.jiajinpeng.BedsSer;
import com.hospital.demo.util.ResultUtils;
import com.hospital.demo.util.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/beds")
@Api(tags={"床位"})
public class BedsCon {
    @Autowired
    private BedsSer bedsSer;

    @ApiOperation(value = "获取全部床位信息", notes = "")
    @GetMapping("/findAllbeds")
    private ResultVO findAllbeds() {
        return ResultUtils.success(bedsSer.Selectallbeds());
    }

    @ApiOperation(value = "通过state查询", notes = "")
    @GetMapping("/findByState")
    private ResultVO findState(@RequestParam(name = "state",defaultValue = "null")String state) {
        return ResultUtils.success(bedsSer.SelectByStateBeds(state));
    }

    @ApiOperation(value = "插入床位", notes = "")
    @PostMapping("/insert")
    private ResultVO insertbed(Beds beds) {
        return ResultUtils.success(bedsSer.insertBeds(beds));
    }

    @ApiOperation(value = "更新床位", notes = "")
    @PostMapping("/update")
    private ResultVO updatebed(Beds beds) {
        return ResultUtils.success(bedsSer.updateBeds(beds));
    }
}
